home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: Capturing useful return values from the parallel port
- Date: 19 Mar 1996 07:47 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <19MAR199607471267@erich.triumf.ca>
- References: <4ilur8$hgi@lyra.csx.cam.ac.uk>
- NNTP-Posting-Host: erich.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4ilur8$hgi@lyra.csx.cam.ac.uk>, mae20@cus.cam.ac.uk (M.A. Elliott) writes...
- >I am building a small routine which is designed to return values 1-4 from a four
- >button resposne box plugged into the parallel port. The buttons normally return
- >bits 0 through 3 but I am having problems converting these, elegantly, into the
- >required values.
- >@define PORTID 0x379
- >unsigned pressedKey(void)
- > {
- >
- > return ((inportb(PORTID) >> 6) ^1);
-
- If the switches are in bits 0 - 3, this shift will throw them away!
-
- How about:
- switch(inport(PORTID)) {
- case 1: /* switch 1 hit */
- break;
- case 2: /* switch 2 hit */
- break;
- case 4: /* switch 3 hit */
- break;
- case 8: /* switch 4 hit */
- break;
- default: /* nothing interesting happened */
- break;
- }
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
-
-